<?php
class ApiCenter_ProductApi_Model_Api2_Product_Image_Rest_Admin_V1 extends  ApiCenter_ProductApi_Model_Api2_Product_Image_Rest{
    
    
    protected function _update($filteredData){
        
        $id = $this->getRequest()->getParam("id");
        $product = Mage::getModel("catalog/product")->load($id);
        try {
            $files  =  $this->uploadImage($product,$filteredData);
            $res['status'] = 1;
            $res['info'] = $files;
        } catch (Exception $e) {
            $res['status'] = 0;
            $res['info'] = $e->getMessage();
        }
        $this->_render($res);
    }
    
    protected  function _multiUpdate($filteredData){
        
        $product = Mage::getModel("catalog/product");

        if(isset($filteredData['file']) && is_array($filteredData['file'])){
                foreach ($filteredData['file'] as $v){
                    $files[] =  $this->uploadImage($product,$v);
                }
        }else{
            $this->_critical("格式错误",400);
        }
        try {
            $res['status'] = 1;
            $res['info'] = $files;
        } catch (Exception $e) {
            Mage::log("上传图片数据出错",1,"upload.log");
            Mage::log($e->getMessage());
            $res['status'] = 0;
            $res['info'] = $e->getMessage();
        }
        $this->_render($res);
    }
}